<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>LCV Framework: test-cam.c Quellcode</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Erzeugt von Doxygen 1.5.3 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Hauptseite</span></a></li>
    <li><a href="classes.html"><span>Datenstrukturen</span></a></li>
    <li class="current"><a href="files.html"><span>Dateien</span></a></li>
  </ul>
</div>
<h1>test-cam.c</h1><a href="test-cam_8c.html">gehe zur Dokumentation dieser Datei</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00003"></a>00003 <span class="preprocessor">#include "<a class="code" href="cam_8h.html" title="Definiert die abstrakte Schnittstelle zur Kamera.">lcv/cam.h</a>"</span>
<a name="l00004"></a>00004 <span class="preprocessor">#include "<a class="code" href="config_8h.html">config.h</a>"</span>
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="test-dip_8h.html#a0e57a59358244c8234ccc3b7ec4f65c">00006</a> <span class="keywordtype">void</span> <a class="code" href="test-cam_8c.html#a0e57a59358244c8234ccc3b7ec4f65c" title="Testet die cam library des LCV-Frameworks.">test_cam</a>()
<a name="l00007"></a>00007 {
<a name="l00008"></a>00008         <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> value = 0;
<a name="l00009"></a>00009         
<a name="l00010"></a>00010         printf(<span class="stringliteral">"Testing registers:\n"</span>); 
<a name="l00011"></a>00011         printf(<span class="stringliteral">"read analog_gain... "</span>);
<a name="l00012"></a>00012         fflush(stdout);
<a name="l00013"></a>00013         value = <a class="code" href="cam-linux32_8c.html#87fa1748b8561b93887e94d6a1e46dfa" title="Liest den Wert einer Registerkonfiguration.">lcv_config_read</a>(<a class="code" href="lcv-config_8h.html#d3762002f8bd18b39367f5ce632e6f48">REG_ANALOG_GAIN</a>);
<a name="l00014"></a>00014         printf(<span class="stringliteral">"value is: %d\n"</span>, value);
<a name="l00015"></a>00015                 
<a name="l00016"></a>00016         printf(<span class="stringliteral">"write analog_gain to 20... "</span>);  
<a name="l00017"></a>00017         fflush(stdout);
<a name="l00018"></a>00018         <span class="keywordflow">if</span>(<a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#d3762002f8bd18b39367f5ce632e6f48">REG_ANALOG_GAIN</a>, 20))
<a name="l00019"></a>00019         {
<a name="l00020"></a>00020                 printf(<span class="stringliteral">"register written\n"</span>);
<a name="l00021"></a>00021         } <span class="keywordflow">else</span> {
<a name="l00022"></a>00022                 printf(<span class="stringliteral">"\nError: register not written\n"</span>);
<a name="l00023"></a>00023                 printf(<span class="stringliteral">"Aborting Test\n"</span>);
<a name="l00024"></a>00024                 exit(-1);
<a name="l00025"></a>00025         }
<a name="l00026"></a>00026            
<a name="l00027"></a>00027         printf(<span class="stringliteral">"read analog_gain..."</span>);  
<a name="l00028"></a>00028         fflush(stdout);
<a name="l00029"></a>00029         value = <a class="code" href="cam-linux32_8c.html#87fa1748b8561b93887e94d6a1e46dfa" title="Liest den Wert einer Registerkonfiguration.">lcv_config_read</a>(<a class="code" href="lcv-config_8h.html#d3762002f8bd18b39367f5ce632e6f48">REG_ANALOG_GAIN</a>);
<a name="l00030"></a>00030         printf(<span class="stringliteral">"value is: %d\n"</span>, value);
<a name="l00031"></a>00031                 
<a name="l00032"></a>00032         printf(<span class="stringliteral">"read illegal register... "</span>);    
<a name="l00033"></a>00033         fflush(stdout);
<a name="l00034"></a>00034         <a class="code" href="cam-linux32_8c.html#87fa1748b8561b93887e94d6a1e46dfa" title="Liest den Wert einer Registerkonfiguration.">lcv_config_read</a>(99);
<a name="l00035"></a>00035         printf(<span class="stringliteral">"ok\n"</span>); 
<a name="l00036"></a>00036         
<a name="l00037"></a>00037         <span class="comment">/*</span>
<a name="l00038"></a>00038 <span class="comment">        printf("write illegal register... ");   </span>
<a name="l00039"></a>00039 <span class="comment">        if(lcv_config_write(99, 20) &gt; 0)</span>
<a name="l00040"></a>00040 <span class="comment">        {</span>
<a name="l00041"></a>00041 <span class="comment">                printf("\nError: Illegal value was not detected\n");</span>
<a name="l00042"></a>00042 <span class="comment">                printf("Aborting Test\n");</span>
<a name="l00043"></a>00043 <span class="comment">                exit(-1);</span>
<a name="l00044"></a>00044 <span class="comment">        } else {</span>
<a name="l00045"></a>00045 <span class="comment">                printf("detected (returned an error-msg)\n");</span>
<a name="l00046"></a>00046 <span class="comment">        }</span>
<a name="l00047"></a>00047 <span class="comment">        */</span>
<a name="l00048"></a>00048         
<a name="l00049"></a>00049         
<a name="l00050"></a>00050         <span class="comment">/* Kamera konfigurieren*/</span>
<a name="l00051"></a>00051         printf(<span class="stringliteral">"configure camera... "</span>);
<a name="l00052"></a>00052         fflush(stdout);
<a name="l00053"></a>00053         
<a name="l00054"></a>00054         <span class="comment">/* Reset */</span>
<a name="l00055"></a>00055         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#d6a95c96a883b809b1bf9c16446d0735">REG_RESET</a>, 1);
<a name="l00056"></a>00056 
<a name="l00057"></a>00057         <span class="comment">/* Turn on Snapshot mode (set bit 4 high) */</span>
<a name="l00058"></a>00058         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#0382141855348b2e0e592e4838675d90">REG_CHIP_CONTROL</a>, 0x398);
<a name="l00059"></a>00059                         
<a name="l00060"></a>00060         <span class="comment">/* Color mode (0x0F set bit 2) */</span>
<a name="l00061"></a>00061         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#b9ae1be39ba0a4a1d78d753776e03855">REG_PIXEL_OPERATION_MODE</a>, 0x11); <span class="comment">//off (c.f. mt9v032.c driver)</span>
<a name="l00062"></a>00062         
<a name="l00063"></a>00063         <span class="comment">/* Mirror: Row Flip */</span>
<a name="l00064"></a>00064         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#a92d64afb815d3056752d004f9628d99">REG_READ_MODE</a>, 0x0320);
<a name="l00065"></a>00065         
<a name="l00066"></a>00066         <span class="comment">/* Set AGC/AEC */</span>
<a name="l00067"></a>00067         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#162d9605325ae8e541d315939a24dccf">REG_AEC_AGC_ENABLE</a>, 0x3);
<a name="l00068"></a>00068 
<a name="l00069"></a>00069         <span class="comment">/* Set Noise Correction */</span> 
<a name="l00070"></a>00070         <a class="code" href="cam-linux32_8c.html#7ad8b70964b854eb97169bd1469ba161" title="Schreibt eine Registerkonfiguration.">lcv_config_write</a>(<a class="code" href="lcv-config_8h.html#f55f93c7ecd560a81550d1bd595c2d70">REG_ROW_NOISE_CORR_CTRL_1</a>, 0x34);
<a name="l00071"></a>00071         
<a name="l00072"></a>00072         printf(<span class="stringliteral">"ok\n"</span>);
<a name="l00073"></a>00073         
<a name="l00074"></a>00074                 
<a name="l00075"></a>00075         printf(<span class="stringliteral">"Testing Capture-Functions:\n"</span>);
<a name="l00076"></a>00076         printf(<span class="stringliteral">"capture frame... "</span>);
<a name="l00077"></a>00077         fflush(stdout);
<a name="l00078"></a>00078         <a class="code" href="structlcv__picture.html" title="Bilderstruktur für unsigned 8-bit Bilder.">lcv_picture</a> p_captured = <a class="code" href="cam-linux32_8c.html#abd5b4037cc6f83069eaf5718d5ed872" title="Holt ein Bild von der Kamera.">lcv_capture_frame</a>(<a class="code" href="config_8h.html#3d3267b8ecabd35fd473c13d616e53d9">FULLSIZE_INPUT_IMAGE</a>);       
<a name="l00079"></a>00079         printf(<span class="stringliteral">"ok\n"</span>); 
<a name="l00080"></a>00080         
<a name="l00081"></a>00081         
<a name="l00082"></a>00082         printf(<span class="stringliteral">"writing captured frame... "</span>);
<a name="l00083"></a>00083         fflush(stdout);
<a name="l00084"></a>00084         <a class="code" href="bmp_8c.html#460186983c9e59d93ee69a459c5d0815" title="Speichert ein lcv_picture Strukt im BMP-Format ab.">lcv_write_bmp</a>(p_captured, <span class="stringliteral">"cam_capture_frame.bmp"</span>);
<a name="l00085"></a>00085         printf(<span class="stringliteral">"ok\n"</span>); 
<a name="l00086"></a>00086         
<a name="l00087"></a>00087         <span class="comment">/*</span>
<a name="l00088"></a>00088 <span class="comment">        </span>
<a name="l00089"></a>00089 <span class="comment">        printf("capture region... ");</span>
<a name="l00090"></a>00090 <span class="comment">        fflush(stdout);</span>
<a name="l00091"></a>00091 <span class="comment">        p_captured = lcv_capture_region(5, 5, 350, 223, SMALL_INPUT_IMAGE);</span>
<a name="l00092"></a>00092 <span class="comment">        //lcv_write_bmp(p_captured, "cam_capture_region.bmp");</span>
<a name="l00093"></a>00093 <span class="comment">        printf("ok\n");</span>
<a name="l00094"></a>00094 <span class="comment">        </span>
<a name="l00095"></a>00095 <span class="comment">        printf("capture frame again... ");</span>
<a name="l00096"></a>00096 <span class="comment">        fflush(stdout);</span>
<a name="l00097"></a>00097 <span class="comment">        p_captured = lcv_capture_frame(FULLSIZE_INPUT_IMAGE);</span>
<a name="l00098"></a>00098 <span class="comment">        printf("ok\n"); </span>
<a name="l00099"></a>00099 <span class="comment">        </span>
<a name="l00100"></a>00100 <span class="comment">        */</span>
<a name="l00101"></a>00101 }
</pre></div><hr size="1"><address style="text-align: right;"><small>Erzeugt am Thu Dec 13 14:01:49 2007 für LCV Framework von&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>
